package com.ibeeking.gmc.global.g.rest.service;

import com.ibeeking.found.common.entity.OperatorDTO;
import com.ibeeking.found.common.entity.TenantExtendInfo;
import com.ibeeking.gmc.global.api.common.dto.TenantDTO;
import com.ibeeking.gmc.global.api.common.dto.TenantListDTO;
import com.ibeeking.gmc.global.api.common.param.TenantParam;
import com.ibeeking.gmc.global.service.common.dos.TenantDO;
import com.ibeeking.gmc.global.service.common.param.TenantPermissionParam;
import com.ibeeking.gmc.global.service.common.query.TenantEffectiveQuery;
import com.ibeeking.gmc.global.service.common.query.TenantPageQuery;
import com.ibeeking.gmc.global.service.common.query.TenantQuery;
import com.ibeeking.gmc.global.service.common.vo.TenantEffectiveVO;
import com.ibeeking.gmc.global.service.common.vo.TenantVO;
import com.ibeeking.gmc.global.service.common.vo.TenantViewVO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;


/**
 * ITenantService
 *
 * @Author ibeeking
 * @Date 2020-12-24 09:21
 */
public interface ITenantService extends IService<TenantDO> {


    /***
     * 分页查询
     */
    Page<TenantVO> pageList(TenantPageQuery tenantPageQuery);
    /***
     * 新增
     */
    Boolean add(com.ibeeking.gmc.global.service.common.param.TenantParam tenantParam);

    /***
     * 修改
     */
    Boolean modify(com.ibeeking.gmc.global.service.common.param.TenantParam tenantParam);

    /***
     * 跟新扩展信息
     */
    Boolean updateTenantExtendInfo(TenantExtendInfo extendInfo);
    /***
     * 通过id查询
     */
    TenantVO view(Integer id);

    /***
     * 通过id查询租户认证查询
     */
    TenantViewVO viewCertInfo(Integer tenantid);

    /***
     * 修改状态
     */
    Boolean changeStatus(Integer id, Integer status, Long modifyBy);

    /***
     * 通过id删除
     */
    Boolean del(Integer id);

    /**
     * 有效租户列表
     *
     * @param tenantQuery
     * @return
     */
    Page<TenantVO> list(TenantQuery tenantQuery);

    /**
     * 使用id查租户
     *
     * @param id
     * @return
     */
    TenantDTO queryTenantById(Integer id);

    String queryTenantIndustryById(Integer id);

    List<TenantListDTO> queryEffectiveTenants();

    List<TenantListDTO> queryUserTenantsByIds(List<Integer> ids);

    Boolean modifyTenant(TenantParam tenantParam);

    /**
     * 查询所有有效租户id列表
     *
     * @return
     */
    List<Integer> queryTenantIds();

    /**
     * 根据用户ids查询用户基本信息
     *
     * @return
     */
    List<OperatorDTO> queryByUserIds(Integer tenantId, List<Long> userIds);

    Boolean initTenant(Long userId, Integer tenantId, Long datasourceId);

    String readTenantInitLog(Long userId, Integer tenantId);

    Boolean insertAndUpdateTenantDatasource(Integer tenantId, Long datasourceId);

    Boolean deleteTenantDatasource(Integer tenantId);

    Boolean changeInit(Integer tenantId, Integer status);

    Boolean recovery(Long userId, Integer tenantId);

    List<TenantEffectiveVO> effectiveList(TenantEffectiveQuery query);

    List<String> queryPermissionIdsByTenantId(Integer tenantId, String module);

    /**
     * 配置租户菜单
     *
     * @param param
     * @return
     */
    Boolean configurePermission(TenantPermissionParam param);

    TenantDTO queryTenantByCode(String code);
}
